package com.vogue.flowmeter.api.entity;

import com.vogue.flowmeter.util.DateUtils;
import java.io.Serializable;
import java.util.Calendar;

/**
 * 日历时钟
 */
public class CalendarClock implements Serializable {
    private int year;
    private int monthOfYear;
    private int dayOfMonth;
    private int hourOfDay;
    private int minute;
    private int second;

    public CalendarClock() {
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonthOfYear() {
        return monthOfYear;
    }

    public void setMonthOfYear(int monthOfYear) {
        this.monthOfYear = monthOfYear;
    }

    public int getDayOfMonth() {
        return dayOfMonth;
    }

    public void setDayOfMonth(int dayOfMonth) {
        this.dayOfMonth = dayOfMonth;
    }

    public int getHourOfDay() {
        return hourOfDay;
    }

    public void setHourOfDay(int hourOfDay) {
        this.hourOfDay = hourOfDay;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    public int getSecond() {
        return second;
    }

    public void setSecond(int second) {
        this.second = second;
    }

    /**
     * 获取6字节日历时钟的BCD码（10进制）
     * @return
     */
    public String getBCDCalendarClock(){
        Calendar calendar=Calendar.getInstance();
        calendar.set(this.getYear(),this.getMonthOfYear(),this.getDayOfMonth(),this.getHourOfDay(),this.getMinute(),this.getSecond());
        return DateUtils.format(calendar.getTime().getTime(),DateUtils.BCD_DATE_FORMAT);
    }

    /**
     * 获取日历时钟字符串
     * @return
     */
    public String getCalendarClock(){
        Calendar calendar=Calendar.getInstance();
        calendar.set(this.getYear(),this.getMonthOfYear(),this.getDayOfMonth(),this.getHourOfDay(),this.getMinute(),this.getSecond());
        return DateUtils.format(calendar.getTime().getTime(),DateUtils.DEFAULT_DATE_FORMAT);
    }

    @Override
    public String toString() {
        return "CalendarClock{" +
                "year=" + year +
                ", monthOfYear=" + monthOfYear +
                ", dayOfMonth=" + dayOfMonth +
                ", hourOfDay=" + hourOfDay +
                ", minute=" + minute +
                ", second=" + second +
                '}';
    }
}
